import type { EChartsOption } from 'echarts';
//import { reflectOptions } from '/@/views/thingsborad/dashboards/components/ConfigureDashboard/components/modalClassify/chartModal/chartModal.data';
export function publicChartOptions(formData: Recordable): EChartsOption {
  const { dataZoom, _theme, tooltip, grid } = formData;
  return {
    grid: {
      left: `${grid.left}%`,
      right: `${grid.right}%`,
      bottom: `${grid.bottom}%`,
      top: `${grid.top}%`,
      containLabel: true,
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'shadow',
      },
      ...tooltip,
    },
    dataZoom,
    xAxis: {
      type: 'time',
      // minInterval: 3600 * 1000 * 24,
      // maxInterval: 3600 * 1000 * 24,
      // boundaryGap: false,
      // axisLabel: {
      //   formatter: {
      //     year: '{yyyy}',
      //     month: '{MMM}',
      //     day: '{d}',
      //     hour: '{HH}:{mm}',
      //     minute: '{HH}:{mm}',
      //     second: '{HH}:{mm}:{ss}',
      //     millisecond: '{hh}:{mm}:{ss} {SSS}',
      //     none: '{yyy}-{MM}-{dd} {hh}:{mm}:{ss} {SSS}',
      //   },
      // },
    },
    yAxis: {
      type: 'value',
      splitLine: {
        show: true,
        lineStyle: {
          type: 'dashed',
        },
      },
    },
  };
}
// 设置示例数据
export function setChartExampleData(formData: Recordable) {
  let options: EChartsOption = {};
  if (formData.chartType == 'line') {
    options = {
      ...publicChartOptions(formData),
      legend: {
        orient: formData.legend.orient || 'horizontal',
        type: 'scroll',
        left: `${formData.legend.left}%`,
        top: `${formData.legend.top}%`,
        /* right: `${formData.legend.right}%`,
        bottom: `${formData.legend.bottom}%`, */
        itemWidth: 10,
        itemHeight: 2,
        data: [
          {
            name: '运行设备数',
            itemStyle: { opacity: 0 },
          },
        ],
      },
      series: [
        {
          name: '运行设备数',
          data: [],
          type: formData.chartType,
          symbol: 'none',
          itemStyle: {
            color: '#126FE1',
          },
        },
      ],
    };
  } else if (formData.chartType == 'bar') {
    options = {
      ...publicChartOptions(formData),
      legend: {
        orient: formData.legend.orient || 'horizontal',
        type: 'scroll',
        left: `${formData.legend.left}%`,
        // right: `${formData.legend.right}%`,
        // bottom: `${formData.legend.bottom}%`,
        top: `${formData.legend.top}%`,
        itemWidth: 10,
        itemHeight: 10,
        data: [
          {
            name: '运行设备数',
          },
          {
            name: '故障设备数',
          },
        ],
      },
      series: [
        {
          name: '运行设备数',
          data: [
            [1731369600000, 40],
            [1731373200000, 45],
            [1731376800000, 30],
            [1731380400000, 35],
            [1731384000000, 45],
            [1731387600000, 45],
            [1731391200000, 55],
            [1731394800000, 45],
            [1731398400000, 46],
            [1731402000000, 55],
            [1731405600000, 49],
            [1731409200000, 42],
            [1731412800000, 38],
            [1731416400000, 37],
            [1731420000000, 39],
            [1731423600000, 38],
          ],
          type: formData.chartType,
          itemStyle: {
            color: '#00C774',
          },
        },
        {
          name: '故障设备数',
          data: [
            [1731369600000, 10],
            [1731373200000, 12],
            [1731376800000, 13],
            [1731380400000, 13],
            [1731384000000, 13],
            [1731387600000, 14],
            [1731391200000, 14],
            [1731394800000, 14],
            [1731398400000, 18],
            [1731402000000, 18],
            [1731405600000, 16],
            [1731409200000, 16],
            [1731412800000, 16],
            [1731416400000, 15],
            [1731420000000, 14],
            [1731423600000, 14],
          ],
          type: formData.chartType,
          itemStyle: {
            color: '#FFCF33',
          },
        },
      ],
    };
  } else if (formData.chartType == 'lineBar') {
    options = {
      ...publicChartOptions(formData),
      legend: {
        orient: formData.legend.orient || 'horizontal',
        type: 'scroll',
        left: `${formData.legend.left}%`,
        top: `${formData.legend.top}%`,
        bottom: '10%',
        itemWidth: 10,
        itemHeight: 10,
        data: [
          {
            name: '运行设备数',
          },
          {
            name: '故障设备数',
            itemStyle: { opacity: 0 },
          },
        ],
      },
      yAxis: [
        {
          type: 'value',
          name: '运行设备数(台)',
          position: 'left',
          alignTicks: true,
          axisLine: {
            show: true,
            lineStyle: {
              // color: '#FFCF33',
            },
          },
          axisLabel: {
            formatter: '{value}',
          },
          splitLine: {
            show: true,
            lineStyle: {
              type: 'dashed',
            },
          },
        },
        {
          type: 'value',
          name: '故障设备数(台)',
          position: 'right',
          alignTicks: true,
          axisLine: {
            show: true,
            lineStyle: {
              // color: '#00C774',
            },
          },
          axisLabel: {
            formatter: '{value}',
          },
          splitLine: {
            show: true,
            lineStyle: {
              type: 'dashed',
            },
          },
        },
      ],
      series: [
        {
          name: '故障设备数',
          type: 'line',
          color: '#FFCF33',
          yAxisIndex: 1,
          // itemStyle: { opacity: 0 },
          data: [
            [1731355200000, 2],
            [1731358800000, 2],
            [1731362400000, 3],
            [1731366000000, 5],
            [1731369600000, 7],
            [1731373200000, 8],
            [1731376800000, 6],
            [1731380400000, 6],
            [1731384000000, 5],
            [1731387600000, 9],
            [1731391200000, 9],
            [1731394800000, 10],
            [1731398400000, 10],
            [1731402000000, 9],
            [1731405600000, 8],
            [1731409200000, 9],
            [1731412800000, 7],
            [1731416400000, 7],
            [1731420000000, 7],
            [1731423600000, 5],
          ],
        },
        {
          name: '运行设备数',
          type: 'bar',
          color: '#00C774',
          yAxisIndex: 0,
          data: [
            [1731355200000, 38],
            [1731358800000, 38],
            [1731362400000, 39],
            [1731366000000, 38],
            [1731369600000, 40],
            [1731373200000, 45],
            [1731376800000, 30],
            [1731380400000, 35],
            [1731384000000, 45],
            [1731387600000, 45],
            [1731391200000, 55],
            [1731394800000, 45],
            [1731398400000, 46],
            [1731402000000, 55],
            [1731405600000, 49],
            [1731409200000, 42],
            [1731412800000, 38],
            [1731416400000, 37],
            [1731420000000, 39],
            [1731423600000, 38],
          ],
        },
      ],
    };
  } else if (formData.chartType == 'pie') {
    const { legend, name, chartType, radius, tooltip, emphasis } = formData;
    options = {
      tooltip: {
        /* backgroundColor: tooltip.backgroundColor,
        borderColor: tooltip.borderColor,
        borderWidth: tooltip.borderWidth,
        textStyle: {
          color: tooltip.textStyle.color,
          fontSize: tooltip.textStyle.fontSize,
          fontWeight: tooltip.textStyle.fontWeight,
        }, */
        trigger: 'item',
        ...tooltip,
      },
      legend: {
        /* top: '5%',
        left: 'center', */
        left: `${legend.left ? legend.left + '%' : 'center'}`,
        top: `${legend.top}%`,
        itemGap: 20,
        itemWidth: 12,
        itemHeight: 12,
        textStyle: {
          color: 'rgba(0, 0, 0, 0.65)',
          fontSize: 14,
          fontStyle: 'normal',
          fontWeight: 'normal',
        },
      },
      series: [
        {
          name: name,
          type: chartType,
          // radius: `${radius}%`,
          radius: [`${radius.innerRadius}%`, `${radius.outRadius}%`],
          avoidLabelOverlap: false,
          label: {
            show: false,
            position: 'center',
          },
          emphasis: {
            label: {
              show: true,
              fontSize: 40,
              fontWeight: 'bold',
            },
            itemStyle: {
              shadowOffsetX: 0,
              ...(emphasis
                ? {
                    shadowBlur: emphasis.itemStyle.shadowBlur,
                    shadowColor: emphasis.itemStyle.shadowColor,
                  }
                : ''),
            },
          },
          labelLine: {
            show: false,
          },
          data: [
            { value: 1048, name: '设备1', itemStyle: { color: '#5B8FF9' } },
            { value: 735, name: '设备2', itemStyle: { color: '#CDDDFD' } },
            { value: 580, name: '设备3', itemStyle: { color: '#62DDAA' } },
            { value: 484, name: '设备4', itemStyle: { color: '#9661BC' } },
            { value: 300, name: '设备5', itemStyle: { color: '#78D3F8' } },
          ],
        },
      ],
    };
  } else if (formData.chartType == 'gauge') {
    const { isShow, barOne, barTwo, data, axisLine } = formData;
    const series = [
      {
        type: 'bar',
        data: [
          {
            value: data,
            itemStyle: {
              color: (barOne && barOne.itemStyle.color) || '#23B0B0',
              // shadowColor: 'rgba(35, 176, 176, 0.5)',
              // shadowBlur: 10,
            },
          },
        ],
        barGap: '-100%',
        coordinateSystem: 'polar',
        roundCap: true,
        z: 2,
        animationDuration: 2000,
      },
      {
        //底层圆环
        type: 'bar',
        data: [
          {
            value: 100,
            itemStyle: {
              color: (barTwo && barTwo.itemStyle.color) || '#EBEDF5',
            },
          },
        ],
        barGap: '-100%',
        coordinateSystem: 'polar',
        roundCap: true,
        z: 1,
        animation: false,
      },
      {
        name: '',
        type: 'gauge',
        //startAngle: 180,
        //endAngle: 0,
        min: 0,
        max: 100,
        splitNumber: 10,
        radius: '70%', //图表尺寸
        center: ['50%', '50%'],
        title: {
          fontSize: 14,
        },
        detail: {
          formatter: '{r1|{value}}{r2|%}',
          color: 'auto',
          rich: {
            r1: {
              fontSize: 30,
              verticalAlign: 'bottom',
              padding: [0, 5, -2, 0],
            },
            r2: {
              fontSize: 20,
              verticalAlign: 'bottom',
            },
          },
        },
        anchor: {
          show: true,
          showAbove: true,
          size: 10,
          itemStyle: {
            borderWidth: 2,
            borderColor: '#2262E4',
          },
        },
        pointer: {
          icon: 'path://M2090.36389,615.30999 L2090.36389,615.30999 C2091.48372,615.30999 2092.40383,616.194028 2092.44859,617.312956 L2096.90698,728.755929 C2097.05155,732.369577 2094.2393,735.416212 2090.62566,735.56078 C2090.53845,735.564269 2090.45117,735.566014 2090.36389,735.566014 L2090.36389,735.566014 C2086.74736,735.566014 2083.81557,732.63423 2083.81557,729.017692 C2083.81557,728.930412 2083.81732,728.84314 2083.82081,728.755929 L2088.2792,617.312956 C2088.32396,616.194028 2089.24407,615.30999 2090.36389,615.30999 Z',
          length: '75%',
          width: 10,
          offsetCenter: [0, '5%'],
        },
        progress: {
          roundCap: true,
          show: true,
          width: 0,
        },
        itemStyle: {
          color: '#2262E4',
        },
        data: [
          {
            value: data,
            name: '进度',
          },
        ],
        axisLine: {
          show: true,
          lineStyle: {
            width: axisLine.lineStyle.width || 0,
            shadowBlur: 0,
            color: [
              [0.2, '#23AFAF'],
              [0.4, '#2270DA'],
              [0.6, '#E99D02'],
              [1, '#F45656'],
            ],
          },
        },
        axisTick: {
          show: true,
          lineStyle: {
            color: 'auto',
            width: 2,
          },
          length: 10,
          splitNumber: 5,
        },
        splitLine: {
          show: true,
          length: 12,
          lineStyle: {
            color: 'auto',
            width: 2,
          },
        },
        axisLabel: {
          distance: 5,
          color: '#9BA5BC',
          fontSize: 12,
        },
      },
    ];
    options = {
      // backgroundColor: '#011C2F',
      tooltip: {
        trigger: 'item',
      },
      angleAxis: {
        show: false,
        max: (100 * 360) / 270,
        type: 'value',
        startAngle: 225,
        splitLine: {
          show: false,
        },
      },
      //圆环宽度
      barMaxWidth: 20,
      radiusAxis: {
        show: false,
        type: 'category',
        z: 10,
      },
      polar: {
        //圆环大小
        radius: '160%',
      },
      series: isShow ? series : [series[2]],
    };
  } else if (formData.chartType == 'map') {
    const { tooltip, itemStyle, emphasis, roam, zoom, label } = formData;
    options = {
      tooltip: {
        show: tooltip.show,
        backgroundColor: '#fff',
        // borderColor: '#ff2b73',
        triggerOn: 'mousemove', //click
        enterable: true,
      },
      roam: roam,
      series: [
        {
          name: 'china',
          type: formData.chartType,
          map: 'china',
          colorBy: 'series',
          label: {
            show: label.show,
            color: 'rgba(0, 0, 0, 0.85)',
          },
          itemStyle: {
            areaColor: itemStyle.areaColor,
            borderColor: '#000',
            /* shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)',
            shadowBlur: 10, */
          },
          emphasis: {
            disabled: false,
            label: {
              fontWeight: 'bold',
              fontSize: 16,
              color: '#000',
            },
            itemStyle: {
              areaColor: emphasis.itemStyle.areaColor,
              borderColor: '#000',
              // shadowOffsetX: 0,
              // shadowColor: 'rgba(0, 0, 0, 0.5)',
              // shadowBlur: 10,
            },
          }, //鼠标悬浮效果
          zoom: zoom,
        },
      ],
    };
  } else if (formData.chartType == 'liquidFill') {
    const { totalValue, currentValue } = formData;
    const data = [currentValue / totalValue, totalValue];
    const color = ['#f9dfa9', '#f7cb71', '#faae18'];
    options = {
      title: {
        text: '水球',
        bottom: '2%',
        left: 'center',
      },
      graphic: [
        // 扩展自定义文字
        {
          type: 'text',
          top: '50%',
          left: 'center',
          z: 2,
          // bottom:  -80,
          style: {
            text: data[0] * 100 + '%',
            fill: '#000',
            fontSize: 32,
            fontWeight: 'bold',
          },
        },
        {
          type: 'text',
          left: 'center',
          z: 2,
          top: '45%',
          style: {
            text: data[1] + '台',
            fill: '#000',
            fontSize: 14,
          },
        },
      ],
      series: [
        {
          type: formData.chartType,
          // 数据值，0 到 1 之间的数值
          data: [data[0], data[0], data[0]],
          shape: 'circle', // 形状，默认为圆形
          radius: '80%', // 半径大小
          center: ['50%', '50%'], // 圆心位置
          color: color, // 颜色
          amplitude: 20, //波段幅度
          outline: {
            // 最外层圆
            show: true,
            borderDistance: 10,
            itemStyle: {
              borderColor: color[2],
              borderWidth: 1,
            },
          },
          backgroundStyle: {
            color: '#fff',
          },
          itemStyle: {
            normal: {
              shadowBlur: 0,
            },
          },
          label: {
            normal: {
              show: false,
            },
          },
        },
      ],
    };
  } else if (formData.chartType == 'scatter') {
    const { grid, name, xAxisUnit, yAxisUnit, itemStyle, symbol, animationDelay } = formData;
    options = {
      legend: {},
      grid: {
        left: `${grid.left}%`,
        right: `${grid.right}%`,
        bottom: `${grid.bottom}%`,
        top: `${grid.top}%`,
        containLabel: true,
      },
      xAxis: {
        type: 'value',
        scale: true,
        axisLabel: {
          formatter: `{value} ${xAxisUnit}`,
        },
        splitLine: {
          show: false,
        },
      },
      yAxis: {
        type: 'value',
        scale: true,
        axisLabel: {
          formatter: `{value} ${yAxisUnit}`,
        },
        splitLine: {
          show: false,
        },
      },
      series: [
        {
          name: name,
          type: 'scatter',
          itemStyle: {
            color: itemStyle.color, // 点颜色
          },
          symbol: symbol,
          animationDelay: function (idx) {
            // 动画延迟时间，使得点依次出现
            return idx * animationDelay;
          },
          data: [
            [174, 65.6],
            [175.3, 71.8],
            [193.5, 80.7],
            [186.5, 72.6],
            [187.2, 78.8],
            [181.5, 74.8],
            [184, 86.4],
            [184.5, 78.4],
            [175, 62],
            [184, 81.6],
            [180, 76.6],
            [177.8, 83.6],
            [192, 90],
            [176, 74.6],
            [174, 71],
            [184, 79.6],
            [192.7, 93.8],
            [171.5, 70],
            [173, 72.4],
            [176, 85.9],
            [176, 78.8],
            [180.5, 77.8],
            [172.7, 66.2],
            [176, 86.4],
            [173.5, 81.8],
            [178, 89.6],
            [180.3, 82.8],
            [180.3, 76.4],
            [164.5, 63.2],
            [173, 60.9],
            [183.5, 74.8],
            [175.5, 70],
            [188, 72.4],
            [189.2, 84.1],
            [172.8, 69.1],
            [170, 59.5],
            [182, 67.2],
            [170, 61.3],
            [177.8, 68.6],
            [184.2, 80.1],
            [186.7, 87.8],
            [171.4, 84.7],
            [172.7, 73.4],
            [175.3, 72.1],
            [180.3, 82.6],
            [182.9, 88.7],
            [188, 84.1],
            [177.2, 94.1],
            [172.1, 74.9],
            [167, 59.1],
            [169.5, 75.6],
            [174, 86.2],
            [172.7, 75.3],
            [182.2, 87.1],
            [164.1, 55.2],
            [163, 57],
            [171.5, 61.4],
            [184.2, 76.8],
            [174, 86.8],
            [174, 72.2],
            [177, 71.6],
            [186, 84.8],
            [167, 68.2],
            [171.8, 66.1],
            [182, 72],
            [167, 64.6],
            [177.8, 74.8],
            [164.5, 70],
            [192, 101.6],
            [175.5, 63.2],
            [171.2, 79.1],
            [181.6, 78.9],
            [167.4, 67.7],
            [181.1, 66],
            [177, 68.2],
            [174.5, 63.9],
            [177.5, 72],
            [170.5, 56.8],
            [182.4, 74.5],
            [197.1, 90.9],
            [180.1, 93],
            [175.5, 80.9],
            [180.6, 72.7],
            [184.4, 68],
            [175.5, 70.9],
            [180.6, 72.5],
            [177, 72.5],
            [177.1, 83.4],
            [181.6, 75.5],
            [176.5, 73],
            [175, 70.2],
            [174, 73.4],
            [165.1, 70.5],
            [177, 68.9],
            [192, 102.3],
            [176.5, 68.4],
            [169.4, 65.9],
            [182.1, 75.7],
            [179.8, 84.5],
            [175.3, 87.7],
            [184.9, 86.4],
            [177.3, 73.2],
            [167.4, 53.9],
            [178.1, 72],
            [168.9, 55.5],
            [157.2, 58.4],
            [180.3, 83.2],
            [170.2, 72.7],
            [177.8, 64.1],
            [172.7, 72.3],
            [165.1, 65],
            [186.7, 86.4],
            [165.1, 65],
            [174, 88.6],
            [175.3, 84.1],
            [185.4, 66.8],
            [177.8, 75.5],
            [180.3, 93.2],
            [180.3, 82.7],
            [177.8, 58],
            [177.8, 79.5],
            [177.8, 78.6],
            [177.8, 71.8],
            [177.8, 116.4],
            [163.8, 72.2],
            [188, 83.6],
            [198.1, 85.5],
            [175.3, 90.9],
            [166.4, 85.9],
            [190.5, 89.1],
            [166.4, 75],
            [177.8, 77.7],
            [179.7, 86.4],
            [172.7, 90.9],
            [190.5, 73.6],
            [185.4, 76.4],
            [168.9, 69.1],
            [167.6, 84.5],
            [175.3, 64.5],
            [170.2, 69.1],
            [190.5, 108.6],
            [177.8, 86.4],
            [190.5, 80.9],
            [177.8, 87.7],
            [184.2, 94.5],
            [176.5, 80.2],
            [177.8, 72],
            [180.3, 71.4],
            [171.4, 72.7],
            [172.7, 84.1],
            [172.7, 76.8],
            [177.8, 63.6],
            [177.8, 80.9],
            [182.9, 80.9],
            [170.2, 85.5],
            [167.6, 68.6],
            [175.3, 67.7],
            [165.1, 66.4],
            [185.4, 102.3],
            [181.6, 70.5],
            [172.7, 95.9],
            [190.5, 84.1],
            [179.1, 87.3],
            [175.3, 71.8],
            [170.2, 65.9],
            [193, 95.9],
            [171.4, 91.4],
            [177.8, 81.8],
            [177.8, 96.8],
            [167.6, 69.1],
            [167.6, 82.7],
            [180.3, 75.5],
            [182.9, 79.5],
            [176.5, 73.6],
            [186.7, 91.8],
            [188, 84.1],
            [188, 85.9],
            [177.8, 81.8],
            [174, 82.5],
            [177.8, 80.5],
            [171.4, 70],
            [185.4, 81.8],
            [185.4, 84.1],
            [188, 90.5],
            [188, 91.4],
            [182.9, 89.1],
            [176.5, 85],
            [175.3, 69.1],
            [175.3, 73.6],
            [188, 80.5],
            [188, 82.7],
            [175.3, 86.4],
            [170.5, 67.7],
            [179.1, 92.7],
            [177.8, 93.6],
            [175.3, 70.9],
            [182.9, 75],
            [170.8, 93.2],
            [188, 93.2],
            [180.3, 77.7],
            [177.8, 61.4],
            [185.4, 94.1],
            [168.9, 75],
            [185.4, 83.6],
            [180.3, 85.5],
            [174, 73.9],
            [167.6, 66.8],
            [182.9, 87.3],
            [160, 72.3],
            [180.3, 88.6],
            [167.6, 75.5],
            [186.7, 101.4],
            [175.3, 91.1],
            [175.3, 67.3],
            [175.9, 77.7],
            [175.3, 81.8],
            [179.1, 75.5],
            [181.6, 84.5],
            [177.8, 76.6],
            [182.9, 85],
            [177.8, 102.5],
            [184.2, 77.3],
            [179.1, 71.8],
            [176.5, 87.9],
            [188, 94.3],
            [174, 70.9],
            [167.6, 64.5],
            [170.2, 77.3],
            [167.6, 72.3],
            [188, 87.3],
            [174, 80],
            [176.5, 82.3],
            [180.3, 73.6],
            [167.6, 74.1],
            [188, 85.9],
            [180.3, 73.2],
            [167.6, 76.3],
            [183, 65.9],
            [183, 90.9],
            [179.1, 89.1],
            [170.2, 62.3],
            [177.8, 82.7],
            [179.1, 79.1],
            [190.5, 98.2],
            [177.8, 84.1],
            [180.3, 83.2],
            [180.3, 83.2],
          ],
        },
      ],
    };
  } else if (formData.chartType == 'effectScatter') {
    const { grid } = formData;
    const DataArr = [
      [1.65, 77.52],
      [1.82, 117.49],
      [1.73, 64.46],
      [1.78, 84.55],
      [1.69, 95.53],
      [1.71, 58.01],
      [1.75, 124.69],
      [1.62, 72.87],
      [1.8, 103.23],
      [1.67, 99.2],
      [1.74, 86.48],
      [1.77, 111.41],
      [1.72, 107.6],
      [1.79, 89.44],
      [1.66, 88.48],
      [1.68, 120.56],
      [1.81, 98.3],
      [1.63, 80.12],
      [1.7, 121.21],
      [1.76, 72.11],
      [1.64, 87.08],
      [1.75, 116.72],
      [1.83, 151.04],
      [1.71, 67.42],
      [1.69, 118.71],
      [1.78, 78.13],
      [1.73, 94.94],
      [1.67, 60.52],
      [1.72, 127.18],
      [1.8, 94.32],
      [1.65, 119.18],
      [1.74, 140.21],
      [1.77, 67.1],
      [1.7, 84.98],
      [1.79, 124.3],
      [1.63, 62.68],
      [1.68, 103.9],
      [1.82, 98.5],
      [1.76, 109.06],
      [1.71, 76.95],
      [1.66, 73.07],
      [1.75, 142.19],
      [1.69, 90.72],
      [1.73, 112.6],
      [1.78, 152.7],
      [1.64, 99.19],
      [1.8, 71.28],
      [1.67, 117.14],
      [1.72, 60.7],
      [1.74, 125.97],
      [1.77, 134.65],
      [1.7, 113.05],
      [1.65, 89.21],
      [1.79, 83.98],
      [1.83, 138.46],
      [1.71, 131.63],
      [1.68, 64.12],
      [1.76, 94.38],
      [1.62, 75.2],
      [1.73, 144.54],
      [1.78, 110.54],
      [1.69, 69.45],
      [1.75, 80.72],
      [1.67, 128.11],
      [1.82, 114.48],
      [1.72, 85.36],
      [1.74, 73.43],
      [1.79, 147.15],
      [1.66, 102.72],
      [1.8, 132.3],
      [1.64, 59.03],
      [1.77, 122.0],
      [1.71, 108.71],
      [1.7, 92.14],
      [1.75, 156.19],
      [1.68, 116.38],
      [1.73, 62.96],
      [1.78, 99.07],
      [1.81, 143.92],
      [1.65, 68.12],
      [1.76, 88.07],
      [1.72, 134.78],
      [1.69, 81.49],
      [1.74, 112.39],
      [1.79, 76.03],
      [1.67, 91.55],
      [1.82, 126.49],
      [1.71, 141.06],
      [1.7, 105.23],
      [1.77, 116.61],
      [1.63, 114.27],
      [1.75, 65.63],
      [1.68, 132.3],
      [1.73, 97.85],
      [1.78, 142.56],
      [1.66, 63.32],
      [1.8, 107.89],
      [1.72, 145.34],
      [1.74, 83.02],
      [1.69, 110.29],
      [1.76, 128.51],
      [1.65, 129.94],
      [1.79, 118.15],
      [1.71, 73.44],
      [1.77, 95.34],
    ];
    options = {
      // ...publicChartOptions(formData),
      grid: {
        left: `${grid.left}%`,
        right: `${grid.right}%`,
        bottom: `${grid.bottom}%`,
        top: `${grid.top}%`,
        containLabel: true,
      },
      xAxis: {
        type: 'value',
        scale: true,
      },
      yAxis: {
        type: 'value',
        scale: true,
      },
      series: [
        {
          type: 'effectScatter',
          data: DataArr,
          // 涟漪动画
          showEffectOn: 'emphaias', // render emphaias
          rippleEffect: {
            scale: 5,
          },
          // 散点大小
          // symbolSize:50
          symbolSize: function (arg) {
            const height = arg[0];
            const weight = arg[1];
            //bmi= 体重 / (身高m*身高m) 大于28 代表肥胖
            const bmi = weight / (height * height);
            if (bmi > 28) {
              return 20;
            }
            return 5;
          },
          itemStyle: {
            color: function (arg) {
              const height = arg.data[0];
              const weight = arg.data[1];
              //   bmi= 体重 / (身高m*身高m) 大于28 代表肥胖
              const bmi = weight / (height * height);
              if (bmi > 28) {
                return 'pink';
              }
              return 'green';
            },
          },
        },
      ],
    };
  } else if (formData.chartType == 'radar') {
    const { legend, radar, data } = formData;
    const indicatorList = [
      { name: '状态1', min: 0 },
      { name: '状态2', min: 0 },
      { name: '状态3', min: 0 },
      { name: '状态4', min: 0 },
      { name: '状态5', min: 0 },
    ];
    options = {
      tooltip: {
        show: true,
      },
      legend: {
        orient: legend.orient || 'horizontal',
        data: [
          {
            name: '上月',
            icon: 'roundRect',
            itemStyle: {
              color: '#4992FF',
              borderWidth: 2, // 设置图例图标的颜色
            },
          },
          {
            name: '本月',
            icon: 'roundRect',
            itemStyle: {
              color: '#00A946',
              borderWidth: 2, // 设置图例图标的颜色
            },
          },
        ],
        top: 20,
        show: true,
        // y: '1',
        // center: 0,
        // itemWidth: 18,
        // itemHeight: 12,
        // itemGap: 60,
        // z: 3,
        // // orient: 'horizontal',
        // textStyle: {
        //   fontSize: 14,
        //   color: '#000',
        // },
      },
      radar: {
        shape: radar.shape || 'polygon',
        center: [`${radar.center.weight}%`, `${radar.center.height}%`], // 外圆的位置
        radius: (radar.radius || 50) + '%',
        name: {
          textStyle: {
            color: '#1F1F1F',
            fontSize: 14,
            fontWeight: 400,
            fontFamily: 'PingFangSC-Regular,PingFang SC',
            fontStyle: 'normal',
          },
        },
        axisName: {
          color: radar.axisName.color || '#1F1F1F',
          fontStyle: 'normal',
          fontSize: 14,
          fontWeight: 400,
        },
        axisLabel: {
          textStyle: {
            color: '#000',
            fontWeight: 'bold',
          },
        },
        // TODO:
        indicator: indicatorList,
        splitArea: {
          // 坐标轴在 grid 区域中的分隔区域，默认不显示。
          show: true,
          areaStyle: {
            // 分隔区域的样式设置。
            color: ['rgba(250,250,250,0.3)', 'rgba(200,200,200,0.3)'], // 分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
          },
        },
        //尖点连接线
        axisLine: {
          // 指向外圈文本的分隔线样式
          lineStyle: {
            color: '#E0E6F1',
            width: 2,
          },
        },
        splitLine: {
          lineStyle: {
            type: 'solid',
            color: '#E0E6F1', // 分隔线颜色
            width: 3, // 分隔线线宽
          },
        },
      },
      series: [
        {
          type: 'radar',
          data: [
            {
              value: [50, 60, 40, 10, 0],
              name: '上月',
              symbolSize: [0, 0],
              lineStyle: {
                //边缘颜色
                width: 4,
                color: data.oneIndex.lineStyle.color || 'red',
              },
              itemStyle: {
                color: '#fff',
                borderColor: '#4992FF',
                borderWidth: 1,
                shadowBlur: 8,
                shadowColor: '#4992FF',
              },
            },
            {
              value: [80, 80, 80, 70, 60],
              name: '本月',
              symbolSize: [0, 0],
              lineStyle: {
                //边缘颜色
                width: 4,
                color: data.twoIndex.lineStyle.color || '#00A946',
              },
              itemStyle: {
                color: '#fff',
                borderColor: '#00A946',
                borderWidth: 1,
                shadowBlur: 8,
                shadowColor: '#00A946',
              },
            },
          ],
        },
      ],
    };
  } else if (formData.chartType == 'funnel') {
    const { grid, series } = formData;
    options = {
      tooltip: {
        show: false,
      },
      grid: {
        left: `${grid.left}%`,
        right: `${grid.right}%`,
        bottom: `${grid.bottom}%`,
        top: `${grid.top}%`,
        containLabel: true,
      },
      series: [
        {
          name: '漏斗图',
          type: 'funnel',
          width: '55%',
          minSize: '15%',
          gap: 0,
          left: '25%',
          labelLayout: {
            // 文字在漏斗层顶部对齐
            verticalAlign: 'top',
          },
          label: {
            show: true,
            position: 'leftTop',
            color: series.label.color || '#4B5265',
            fontSize: 12,
            formatter: '{b}',
          },
          labelLine: {
            show: true,
          },
          itemStyle: {
            borderColor: '#fff',
            borderWidth: 0,
          },
          data: [
            { name: '浏览1', value: 400, percent: 100 },
            { name: '浏览2', value: 320, percent: 40 },
            { name: '浏览3', value: 200, percent: 20 },
            { name: '浏览4', value: 50, percent: 10 },
            { name: '浏览5', value: 20, percent: 10 },
          ],
        },
        {
          name: '漏斗图',
          type: 'funnel',
          width: '55%',
          minSize: '15%',
          left: '25%',
          gap: 0,
          labelLayout: {
            verticalAlign: 'top',
          },
          label: {
            show: true,
            position: 'rightTop',
            color: series.label.color || '#4B5265',
            fontSize: 12,
            formatter: (params) => {
              return `${params.data.percent}%`;
            },
          },
          labelLine: {
            show: false,
          },
          itemStyle: {
            borderColor: '#fff',
            borderWidth: 0,
          },
          data: [
            { name: '浏览1', value: 400, percent: 100 },
            { name: '浏览2', value: 320, percent: 40 },
            { name: '浏览3', value: 200, percent: 20 },
            { name: '浏览4', value: 50, percent: 10 },
            { name: '浏览5', value: 20, percent: 8 },
          ],
        },
      ],
    };
  } else if (formData.chartType == 'mfd') {
    const { grid, isShow } = formData;
    function getCurrentDateTime() {
      const now = new Date();
      return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(
        now.getDate(),
      ).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(
        now.getMinutes(),
      ).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`;
    }
    const series = [
      {
        name: '上限',

        type: 'line',
        symbolSize: 0,

        lineStyle: {
          normal: {
            color: '#FF0000',
            width: 0.5,
            type: 'dotted',
          },
        },

        data: [18, 18, 22, 25, 25, 30, 40, 77, 100, 100, 100, 100, 100, 100],
      },
      {
        name: '下限',

        type: 'line',
        symbolSize: 0,
        lineStyle: {
          normal: {
            color: '#FF0000',
            width: 0.5,
            type: 'dotted',
          },
        },
        data: [0, 5, 0, 3, 5, 10, 15, 45, 75, 100, 100, 100, 100, 100],
      },
      {
        name: '目标',

        type: 'line',
        symbolSize: 0,

        lineStyle: {
          normal: {
            color: '#0F870F',
            width: 0.5,
            type: 'dotted',
          },
        },
        data: [9.9, 11.3, 12.3, 13.4, 15.6, 19.9, 26.8, 57.7, 90.8, 100, 100, 100, 100, 100],
      },
      {
        name: '当前值',
        // smooth: true,
        type: 'line',
        symbolSize: 5,
        symbol: 'circle',

        itemStyle: {
          normal: {
            color: '#0000FF',
            label: {
              show: true,
              position: 'top',
              textStyle: {
                color: '#0000FF',
              },
            },
          },
        },
        lineStyle: {
          normal: {
            width: 0.8,
          },
        },
        data: [8.6, 10.6, 12.7, 13.8, 16.4, 21.2, 27.8, 59.4, 91.2, 100, 100, 100, 100, 100],
      },
      {
        name: '石油比',
        type: 'gauge',
        center: ['18%', '33%'],
        splitNumber: 5,
        radius: '30%',
        startAngle: 165,
        endAngle: 15,
        min: 4.45,
        max: 7.55,
        pointer: {
          length: '70%',
          width: 3,
          itemStyle: {
            color: 'auto',
          },
        },

        axisLine: {
          // 坐标轴线
          lineStyle: {
            // 属性lineStyle控制线条样式
            width: 10,
            color: [
              [0.25, '#343FE0'],
              [0.75, '#237D1E'],
              [1, '#BF4753'],
            ],
          },
        },
        axisTick: {
          // 坐标轴小标记
          length: 14, // 属性length控制线长
          lineStyle: {
            // 属性lineStyle控制线条样式
            color: 'auto',
          },
        },
        splitLine: {
          // 分隔线
          length: 17, // 属性length控制线长

          lineStyle: {
            // 属性lineStyle（详见lineStyle）控制线条样式
            color: 'auto',
            width: 2,
          },
        },

        detail: { show: false, formatter: '{value}%' },
        data: [
          {
            value: 6.1,
            name: '石油比' + '6.1%',
            title: {
              offsetCenter: [0, '-20%'],
              color: '#000',
              fontSize: 10,
            },
          },
        ],
        // data: [{ value: 5, name: '健康率' }]
      },
      {
        name: '温度',
        type: 'gauge',
        center: ['18%', '50%'],
        splitNumber: 5,
        radius: '30%',
        startAngle: 165,
        endAngle: 15,
        min: 158,
        max: 208,
        pointer: {
          length: '70%',
          width: 3,
          itemStyle: {
            color: 'auto',
          },
        },

        axisLine: {
          // 坐标轴线
          lineStyle: {
            // 属性lineStyle控制线条样式
            width: 10,
            color: [
              [0.25, '#343FE0'],
              [0.75, '#237D1E'],
              [1, '#BF4753'],
            ],
          },
        },
        axisTick: {
          // 坐标轴小标记
          length: 14, // 属性length控制线长
          lineStyle: {
            // 属性lineStyle控制线条样式
            color: 'auto',
          },
        },
        splitLine: {
          // 分隔线
          length: 17, // 属性length控制线长

          lineStyle: {
            // 属性lineStyle（详见lineStyle）控制线条样式
            color: 'auto',
            width: 2,
          },
        },

        detail: { show: false, formatter: '{value}%' },
        data: [
          {
            value: 185,
            name: '温度' + '185%',
            title: {
              offsetCenter: [0, '-20%'],
              color: '#000',
              fontSize: 12,
            },
          },
        ],
      },
    ];
    options = {
      backgroundColor: '#fff',
      color: ['#FF0000', '#FF0000', '#0F870F', '#0000FF'],
      tooltip: {
        trigger: 'axis',
      },
      title: [
        {
          text: `时间：${getCurrentDateTime()}`,
          right: '5%',
          bottom: '10%',
          textStyle: {
            color: '#333',
            fontSize: 12,
            fontWeight: 400,
          },
        },
      ],
      legend: {
        data: ['上限', '下限', '目标', '当前值'],
        textStyle: {
          // color: '33FFFF',
          fontSize: 14,
        },
        itemWidth: 15,
        itemHeight: 15,
        itemGap: 35,
      },
      grid: {
        left: `${grid.left}%`,
        right: `${grid.right}%`,
        bottom: `${grid.bottom}%`,
        top: `${grid.top}%`,
        containLabel: true,
      },
      toolbox: {
        show: false,
        feature: {
          saveAsImage: {},
        },
      },
      xAxis: {
        type: 'category',
        axisLine: {
          lineStyle: {
            color: '#CDCDCD',
          },
        },
        axisTick: {
          show: false,
        },
        axisLabel: {
          // textStyle: {
          //   color: '#D5D5D5',
          // },
        },
        splitLine: {
          show: true,
          lineStyle: {
            color: '#DBDBDB',
            type: 'solid',
            // width: '0.5',
          },
        },

        data: [
          '0.075',
          '0.15',
          '0.3',
          '0.6',
          '1.18',
          '2.36',
          '4.75',
          '9.5',
          '13.2',
          '16',
          '19',
          '26.5',
          '31.5',
          '37.5',
        ],
      },
      yAxis: {
        axisLine: {
          lineStyle: {
            color: '#333',
          },
        },
        name: '通过率',
        splitLine: {
          show: true,
          lineStyle: {
            color: '#DBDBDB',
            type: 'solid',
            // width: '0.5',
          },
        },
        axisTick: {
          show: false,
        },

        axisLabel: {
          // textStyle: {
          //   color: '#333',
          // },
          formatter: '{value}%',
        },
        type: 'value',
      },
      series: isShow ? series : series.filter((e) => e.type != 'gauge'),
    };
  } else if (formData.chartType == 'pictorialBar') {
    const { grid } = formData;
    options = {
      // backgroundColor: '#0e202d',
      title: {
        show: true,
        text: '第三方设备',
        // "subtext": "总数: 599",
        textStyle: {
          color: '#333',
          fontSize: 12,
          fontWeight: 400,
        },
        subtextStyle: {
          color: '#999',
          fontSize: 16,
        },
        left: '1%',
        top: '0',
      },
      grid: {
        left: `${grid.left}%`,
        right: `${grid.right}%`,
        bottom: `${grid.bottom}%`,
        top: `${grid.top}%`,
        containLabel: true,
      },
      tooltip: {},
      xAxis: {
        data: [
          '设备1',
          '设备2',
          '设备3',
          '设备4',
          '设备5',
          '设备6',
          '设备7',
          '设备8',
          '设备9',
          '设备10',
        ],
        axisTick: {
          show: false,
        },
        axisLine: {
          show: false,
        },
        axisLabel: {
          interval: 0,
          // textStyle: {
          //   color: '#beceff',
          //   fontSize: 15,
          // },
          margin: 30, //刻度标签与轴线之间的距离。
        },
      },
      yAxis: {
        splitLine: {
          show: false,
        },
        axisTick: {
          show: false,
        },
        axisLine: {
          show: false,
        },
        axisLabel: {
          show: false,
        },
      },
      series: [
        {
          name: '',
          type: 'pictorialBar',
          symbolSize: [20, 10],
          symbolOffset: [0, -5],
          z: 12,
          data: [
            {
              name: '设备1',
              value: '1000',
              symbolPosition: 'end',
              itemStyle: {
                normal: {
                  color: '#00fff5', //圆柱顶部颜色
                },
              },
            },
            {
              name: '设备2',
              value: '900',
              symbolPosition: 'end',
              itemStyle: {
                normal: {
                  color: '#00fff5', //圆柱顶部颜色
                },
              },
            },
            {
              name: '设备3',
              value: '800',
              symbolPosition: 'end',
              itemStyle: {
                normal: {
                  color: '#00fff5', //圆柱顶部颜色
                },
              },
            },
            {
              name: '设备4',
              value: '700',
              symbolPosition: 'end',
              itemStyle: {
                normal: {
                  color: '#b9b7ff', //圆柱顶部颜色
                },
              },
            },
            {
              name: '设备5',
              value: '600',
              symbolPosition: 'end',
              itemStyle: {
                normal: {
                  color: '#b9b7ff', //圆柱顶部颜色
                },
              },
            },
            {
              name: '设备6',
              value: '500',
              symbolPosition: 'end',
              itemStyle: {
                normal: {
                  color: '#b9b7ff', //圆柱顶部颜色
                },
              },
            },
            {
              name: '设备7',
              value: '400',
              symbolPosition: 'end',
              itemStyle: {
                normal: {
                  color: '#b9b7ff', //圆柱顶部颜色
                },
              },
            },
            {
              name: '设备8',
              value: '300',
              symbolPosition: 'end',
              itemStyle: {
                normal: {
                  color: '#b9b7ff', //圆柱顶部颜色
                },
              },
            },
            {
              name: '设备9',
              value: '200',
              symbolPosition: 'end',
              itemStyle: {
                normal: {
                  color: '#b9b7ff', //圆柱顶部颜色
                },
              },
            },
            {
              name: '设备10',
              value: '100',
              symbolPosition: 'end',
              itemStyle: {
                normal: {
                  color: '#b9b7ff', //圆柱顶部颜色
                },
              },
            },
          ],
        },
        {
          name: '',
          type: 'pictorialBar',
          symbolSize: [20, 10],
          symbolOffset: [0, 5],
          z: 12,
          data: [
            {
              name: '设备1',
              value: '1000',
              itemStyle: {
                normal: {
                  color: '#43bafe', //圆柱底部颜色
                },
              },
            },
            {
              name: '设备2',
              value: '900',
              itemStyle: {
                normal: {
                  color: '#43bafe', //圆柱底部颜色
                },
              },
            },
            {
              name: '设备3',
              value: '800',
              itemStyle: {
                normal: {
                  color: '#43bafe', //圆柱底部颜色
                },
              },
            },
            {
              name: '设备4',
              value: '700',
              itemStyle: {
                // "normal": {
                color: '#e9a5ff', //圆柱底部颜色
                // }
              },
            },
            {
              name: '设备5',
              value: '600',
              itemStyle: {
                normal: {
                  color: '#e9a5ff', //圆柱底部颜色
                },
              },
            },
            {
              name: '设备6',
              value: '500',
              itemStyle: {
                normal: {
                  color: '#e9a5ff', //圆柱底部颜色
                },
              },
            },
            {
              name: '设备7',
              value: '400',
              itemStyle: {
                normal: {
                  color: '#e9a5ff', //圆柱底部颜色
                },
              },
            },
            {
              name: '设备8',
              value: '300',
              itemStyle: {
                normal: {
                  color: '#e9a5ff', //圆柱底部颜色
                },
              },
            },
            {
              name: '设备9',
              value: '200',
              itemStyle: {
                normal: {
                  color: '#e9a5ff', //圆柱底部颜色
                },
              },
            },
            {
              name: '设备10',
              value: '100',
              itemStyle: {
                normal: {
                  color: '#e9a5ff', //圆柱底部颜色
                },
              },
            },
          ],
        },
        {
          name: '',
          type: 'pictorialBar',
          symbolSize: [30, 15],
          symbolOffset: [0, 10],
          z: 11,
          data: [
            {
              name: '设备1',
              value: '1000',
              itemStyle: {
                // "normal": {
                color: 'transparent',
                borderColor: '#43bafe', //底部内圆圈颜色
                borderWidth: '5',
                // }
              },
            },
            {
              name: '设备2',
              value: '900',
              itemStyle: {
                // "normal": {
                color: 'transparent',
                borderColor: '#43bafe', //底部内圆圈颜色
                borderWidth: 5,
                // }
              },
            },
            {
              name: '设备3',
              value: '800',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#43bafe', //底部内圆圈颜色
                  borderWidth: 5,
                },
              },
            },
            {
              name: '设备4',
              value: '700',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#e9a5ff', //底部内圆圈颜色
                  borderWidth: 5,
                },
              },
            },
            {
              name: '设备5',
              value: '600',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#e9a5ff', //底部内圆圈颜色
                  borderWidth: 5,
                },
              },
            },
            {
              name: '设备6',
              value: '500',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#e9a5ff', //底部内圆圈颜色
                  borderWidth: 5,
                },
              },
            },
            {
              name: '设备7',
              value: '400',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#e9a5ff', //底部内圆圈颜色
                  borderWidth: 5,
                },
              },
            },
            {
              name: '设备8',
              value: '300',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#e9a5ff', //底部内圆圈颜色
                  borderWidth: 5,
                },
              },
            },
            {
              name: '设备9',
              value: '200',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#e9a5ff', //底部内圆圈颜色
                  borderWidth: 5,
                },
              },
            },
            {
              name: '设备10',
              value: '100',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#e9a5ff', //底部内圆圈颜色
                  borderWidth: 5,
                },
              },
            },
          ],
        },
        {
          name: '',
          type: 'pictorialBar',
          symbolSize: [60, 30],
          symbolOffset: [0, 18],
          z: 10,
          data: [
            {
              name: '设备1',
              value: '1000',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#43bafe', //底部外圆圈颜色
                  borderType: 'dashed',
                  borderWidth: 5,
                },
              },
            },
            {
              name: '设备2',
              value: '900',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#43bafe', //底部外圆圈颜色
                  borderType: 'dashed',
                  borderWidth: '5',
                },
              },
            },
            {
              name: '设备3',
              value: '800',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#43bafe', //底部外圆圈颜色
                  borderType: 'dashed',
                  borderWidth: 5,
                },
              },
            },
            {
              name: '设备4',
              value: '700',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#e9a5ff', //底部外圆圈颜色
                  borderType: 'dashed',
                  borderWidth: 5,
                },
              },
            },
            {
              name: '设备5',
              value: '600',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#e9a5ff', //底部外圆圈颜色
                  borderType: 'dashed',
                  borderWidth: 5,
                },
              },
            },
            {
              name: '设备6',
              value: '500',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#e9a5ff', //底部外圆圈颜色
                  borderType: 'dashed',
                  borderWidth: 5,
                },
              },
            },
            {
              name: '设备7',
              value: '400',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#e9a5ff', //底部外圆圈颜色
                  borderType: 'dashed',
                  borderWidth: 5,
                },
              },
            },
            {
              name: '设备8',
              value: '300',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#e9a5ff', //底部外圆圈颜色
                  borderType: 'dashed',
                  borderWidth: 5,
                },
              },
            },
            {
              name: '设备9',
              value: '200',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#e9a5ff', //底部外圆圈颜色
                  borderType: 'dashed',
                  borderWidth: 5,
                },
              },
            },
            {
              name: '设备10',
              value: '100',
              itemStyle: {
                normal: {
                  color: 'transparent',
                  borderColor: '#e9a5ff', //底部外圆圈颜色
                  borderType: 'dashed',
                  borderWidth: 5,
                },
              },
            },
          ],
        },
        {
          type: 'bar',
          silent: true,
          barWidth: 20,
          barGap: '-100%',
          itemStyle: {
            normal: {
              color: {
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                type: 'linear',
                global: false,
                colorStops: [
                  {
                    offset: 0,
                    color: 'rgba(0,255,245,0.5)',
                  },
                  {
                    offset: 1,
                    color: '#43bafe', //底部渐变颜色
                  },
                ],
              },
            },
          },
          data: [
            {
              name: '设备1',
              value: '1000',
              label: {
                normal: {
                  show: true,
                  position: 'top',
                  distance: 20,
                  textStyle: {
                    color: '#00fff5', //柱子对应数值颜色
                    fontSize: 20,
                  },
                },
              },
            },
            {
              name: '设备2',
              value: '900',
              label: {
                normal: {
                  show: true,
                  position: 'top',
                  distance: 20,
                  textStyle: {
                    color: '#00fff5', //柱子对应数值颜色
                    fontSize: 20,
                  },
                },
              },
            },
            {
              name: '设备3',
              value: '800',
              label: {
                normal: {
                  show: true,
                  position: 'top',
                  distance: 20,
                  textStyle: {
                    color: '#00fff5', //柱子对应数值颜色
                    fontSize: 20,
                  },
                },
              },
            },
            {
              name: '设备4',
              value: '700',
              label: {
                normal: {
                  show: true,
                  position: 'top',
                  distance: 20,
                  textStyle: {
                    color: '#b9b7ff', //柱子对应数值颜色
                    fontSize: 20,
                  },
                },
              },
              itemStyle: {
                normal: {
                  color: {
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    type: 'linear',
                    global: false,
                    colorStops: [
                      {
                        offset: 0,
                        color: 'rgba(185,183,255,0.5)',
                      },
                      {
                        offset: 1,
                        color: '#e9a5ff', //底部渐变颜色
                      },
                    ],
                  },
                },
              },
            },
            {
              name: '设备5',
              value: '600',
              label: {
                normal: {
                  show: true,
                  position: 'top',
                  distance: 20,
                  textStyle: {
                    color: '#b9b7ff', //柱子对应数值颜色
                    fontSize: 20,
                  },
                },
              },
              itemStyle: {
                normal: {
                  color: {
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    type: 'linear',
                    global: false,
                    colorStops: [
                      {
                        offset: 0,
                        color: 'rgba(185,183,255,0.5)',
                      },
                      {
                        offset: 1,
                        color: '#e9a5ff', //底部渐变颜色
                      },
                    ],
                  },
                },
              },
            },
            {
              name: '设备6',
              value: '500',
              label: {
                normal: {
                  show: true,
                  position: 'top',
                  distance: 20,
                  textStyle: {
                    color: '#b9b7ff', //柱子对应数值颜色
                    fontSize: 20,
                  },
                },
              },
              itemStyle: {
                normal: {
                  color: {
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    type: 'linear',
                    global: false,
                    colorStops: [
                      {
                        offset: 0,
                        color: 'rgba(185,183,255,0.5)',
                      },
                      {
                        offset: 1,
                        color: '#e9a5ff', //底部渐变颜色
                      },
                    ],
                  },
                },
              },
            },
            {
              name: '设备7',
              value: '400',
              label: {
                normal: {
                  show: true,
                  position: 'top',
                  distance: 20,
                  textStyle: {
                    color: '#b9b7ff', //柱子对应数值颜色
                    fontSize: 20,
                  },
                },
              },
              itemStyle: {
                normal: {
                  color: {
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    type: 'linear',
                    global: false,
                    colorStops: [
                      {
                        offset: 0,
                        color: 'rgba(185,183,255,0.5)',
                      },
                      {
                        offset: 1,
                        color: '#e9a5ff', //底部渐变颜色
                      },
                    ],
                  },
                },
              },
            },
            {
              name: '设备8',
              value: '300',
              label: {
                normal: {
                  show: true,
                  position: 'top',
                  distance: 20,
                  textStyle: {
                    color: '#b9b7ff', //柱子对应数值颜色
                    fontSize: 20,
                  },
                },
              },
              itemStyle: {
                normal: {
                  color: {
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    type: 'linear',
                    global: false,
                    colorStops: [
                      {
                        offset: 0,
                        color: 'rgba(185,183,255,0.5)',
                      },
                      {
                        offset: 1,
                        color: '#e9a5ff', //底部渐变颜色
                      },
                    ],
                  },
                },
              },
            },
            {
              name: '设备9',
              value: '200',
              label: {
                normal: {
                  show: true,
                  position: 'top',
                  distance: 20,
                  textStyle: {
                    color: '#b9b7ff', //柱子对应数值颜色
                    fontSize: 20,
                  },
                },
              },
              itemStyle: {
                normal: {
                  color: {
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    type: 'linear',
                    global: false,
                    colorStops: [
                      {
                        offset: 0,
                        color: 'rgba(185,183,255,0.5)',
                      },
                      {
                        offset: 1,
                        color: '#e9a5ff', //底部渐变颜色
                      },
                    ],
                  },
                },
              },
            },
            {
              name: '设备10',
              value: '100',
              label: {
                normal: {
                  show: true,
                  position: 'top',
                  distance: 20,
                  textStyle: {
                    color: '#b9b7ff', //柱子对应数值颜色
                    fontSize: 20,
                  },
                },
              },
              itemStyle: {
                normal: {
                  color: {
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    type: 'linear',
                    global: false,
                    colorStops: [
                      {
                        offset: 0,
                        color: 'rgba(185,183,255,0.5)',
                      },
                      {
                        offset: 1,
                        color: '#e9a5ff', //底部渐变颜色
                      },
                    ],
                  },
                },
              },
            },
          ],
        },
      ],
    };
  }
  return {
    options,
    chartType: formData.chartType,
  };
}

// ws第一次发送消息的处理函数
export const processingChartPublicFormData = (cmdId: number, formData: Recordable) => {
  const sendMsg: Recordable = {
    cmdId,
    query: {
      pageLink: {
        pageSize: 1024,
        page: 0,
        sortOrder: {
          key: {
            type: 'ENTITY_FIELD',
            key: 'createdTime',
          },
          direction: 'DESC',
        },
      },
      entityFields: [
        {
          type: 'ENTITY_FIELD',
          key: 'name',
        },
        {
          type: 'ENTITY_FIELD',
          key: 'label',
        },
        {
          type: 'ENTITY_FIELD',
          key: 'additionalInfo',
        },
      ],
      latestValues: [],
      entityFilter: {
        type: 'singleEntity',
        singleEntity: JSON.parse(formData.deviceId),
      },
    },
  };
  if (formData.chartType === 'line' || formData.chartType == 'bar') {
    sendMsg.query.latestValues = [];
  } else if (formData.chartType == 'pie') {
    formData.series.forEach((item: Recordable) => {
      sendMsg.query.latestValues.push(JSON.parse(item.key));
    });
  }

  return {
    entityDataCmds: [sendMsg],
  };
};
// ws第二次发送消息的处理函数
export const processingChartPrivateFormData = (cmdId: number, formData: Recordable) => {
  // const keys: string[] = [];
  let sendMsg: Recordable = {};
  if (formData.chartType === 'line' || formData.chartType == 'bar') {
    /* formData.series.forEach((item: Recordable) => {
      keys.push(JSON.parse(item.key).key);
    });
    const { agg, limit, times, interval } = formData;
    const endTs = new Date().getTime();
    const startTs = endTs - reflectOptions[times].startTs;
    sendMsg = {
      cmdId,
      historyCmd: {
        keys,
        startTs,
        endTs,
        interval,
        limit: !!limit ? limit : reflectOptions[times].startTs / interval,
        agg,
      },
    }; */
    sendMsg = {
      cmdId,
      tsCmd: {
        agg: 'AVG',
        interval: 1000,
        keys: ['temperature'],
        limit: 61,
        startTs: 1742266899000,
        timeWindow: 61000,
      },
    };
  }
  return {
    entityDataCmds: [sendMsg],
  };
};

// ws第一次获得数据的处理函数
export const processingChartPublicReceiveData = (data: Recordable, formData: Recordable) => {
  let options: EChartsOption = {};
  const { name, chartType, radius, emphasis, tooltip } = formData;

  options = {
    tooltip: {
      // backgroundColor: tooltip.backgroundColor,
      // borderColor: tooltip.borderColor,
      // borderWidth: tooltip.borderWidth,
      // textStyle: {
      //   color: tooltip.textStyle.color,
      //   fontSize: tooltip.textStyle.fontSize,
      //   fontWeight: tooltip.textStyle.fontWeight,
      // },
      ...tooltip,
    },
    series: [
      {
        name: name,
        type: chartType,
        // radius: `${radius}%`,
        radius: [`${radius.innerRadius}%`, `${radius.outRadius}%`],
        data: [
          { value: 1048, name: '示例1' },
          { value: 735, name: '示例2' },
          { value: 580, name: '示例3' },
          { value: 484, name: '示例4' },
          { value: 300, name: '示例5' },
        ],
        emphasis: {
          itemStyle: {
            shadowOffsetX: 0,
            ...(emphasis
              ? {
                  shadowBlur: emphasis.itemStyle.shadowBlur,
                  shadowColor: emphasis.itemStyle.shadowColor,
                }
              : ''),
          },
        },
      },
    ],
  };
  return { options, title: formData.cardTitle };
};
// ws第二次获得数据的处理函数
export const processingChartPrivateReceiveData = (data: Recordable, formData: Recordable) => {
  let legendKeys: string[] = [];
  const series: Recordable[] = [];
  let options: EChartsOption = {};
  if (formData.chartType == 'line' || formData.chartType == 'bar') {
    if (data.update) {
      // 图例数组
      legendKeys = Object.keys(data.update[0].timeseries);
      // 图例对应数据
      formData.series.forEach((item: Recordable) => {
        const seriesData: string[][] = [];
        data.update[0].timeseries[JSON.parse(item.key).key].forEach((item: Recordable) => {
          seriesData.push(Object.values(item));
        });
        series.push({
          name: JSON.parse(item.key).key,
          data: seriesData,
          type: formData.chartType,
          itemStyle: {
            color: item.color,
          },
        });
      });
    }
    options = {
      ...publicChartOptions(formData),
      legend: {
        orient: formData.legend.orient,
        type: 'scroll',
        left: `${formData.legend.left}%`,
        top: `${formData.legend.top}%`,
        data: legendKeys,
      },
      series,
    };
  } else if (formData.chartType == 'pie') {
    if (data.data) {
    }
  }
  return { options, title: formData.cardTitle };
};
